package middleware

import (
	"github.com/gin-gonic/gin"
	log "github.com/sirupsen/logrus"
)

func LoggerError() gin.HandlerFunc {
	return func(ctx *gin.Context) {
		ctx.Next()
		last := ctx.Errors.Last()
		if last != nil {
			msg := ""
			switch last.Type {
			default:
				msg = "未知错误"

			}
			log.Error(msg, " ,route:", ctx.FullPath(), last.Error())
		}
	}
}
